﻿namespace AgileDashboard.AppCode
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;

    using log4net;

    /// <summary>
    /// Simple DTO used to hold iteration data
    /// </summary>
    [Serializable]
    public class Iteration : VersionOneEntity
    {
        private static Dictionary<string, string> _versionOneAttributeNameDictionary;
        private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// The name of the iteration
        /// </summary>
        public string Name { get; set; }
        
        /// <summary>
        /// The date representing the first day of the iteration
        /// </summary>
        public DateTime BeginDate { get; set; }
        
        /// <summary>
        /// The date representing the last day of the iteration
        /// </summary>
        public DateTime EndDate { get; set; }
        
        /// <summary>
        /// The name of the schedule the iteration adheres to
        /// </summary>
        public string Schedule { get; set; }

        public static Dictionary<string, string> VersionOneAttributeNameDictionary
        {
            get
            {
                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("Returning instance of Iteration Attribute Name Dictionary");
                }

                return _versionOneAttributeNameDictionary
                       ?? (_versionOneAttributeNameDictionary = BuildVersionOneAttributeDictionary<Iteration>());
            }
        }
    }
}